home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Data 2002 May / CD Rom Data Mayıs 2002.iso / Freeware / Blitz Basic / data1.cab / Support / help / samples / blackhole.bb < prev    next >
Encoding:
Text File  |  2002-04-10  |  1.6 KB  |  68 lines

  1. ;Starfield demo
  2. ;Copyright ⌐2000 EdzUp
  3. ;written by Ed Upton
  4. ;Graphics 'Borrowed' from Mark Sibly's stars.bmp
  5. ; verified 1.48 4/18/2001
  6.  
  7. ;adjust for more or less stars (500 looks nice)
  8. ;I can get 2500 stars without losing a single frame
  9. Global staramount=1000
  10.  
  11. Graphics 640,480
  12. SetBuffer BackBuffer()
  13.  
  14. Global stara=LoadImage("graphics\star1.bmp")
  15. Global starb=LoadImage("graphics\star2.bmp")
  16. Global starc=LoadImage("graphics\star3.bmp")
  17.  
  18. ;star array
  19. Type star
  20.  Field rad,speed,angle
  21. End Type
  22.  
  23. setupstars()
  24.  
  25. ;main loop
  26. While Not KeyDown(1)
  27.  Cls
  28.  update()
  29.  Flip
  30. Wend
  31. End
  32.  
  33. ;set up stars
  34. Function setupstars()
  35.  For sc=0 To staramount
  36.   stars.star = New star
  37.   stars\rad=Rnd(280)+80
  38.   stars\angle=Rnd(65535)
  39.   stars\speed=Rnd(5)+1
  40.  Next
  41. End Function
  42.  
  43. ;update each star in turn
  44. Function update()
  45.  For stars.star = Each star
  46.   xx=320+Sin((2*stars\angle)*Pi/360)*stars\rad
  47.   yy=240+Cos((2*stars\angle)*Pi/360)*stars\rad
  48.   ;replace star if it goes off screen
  49.   If xx>290 And xx<350 And yy>210 And yy<270
  50.    stars\rad=Rnd(40)+400
  51.    stars\angle=Rnd(65535)
  52.    stars\speed=Rnd(5)+1
  53.   EndIf
  54.   stars\angle=stars\angle+100
  55.   stars\rad=stars\rad-(stars\speed*2)
  56.   If stars\speed=1 Then DrawImage starc,xx,yy
  57.   If stars\speed=2 Or stars\speed=3 Then DrawImage starb,xx,yy
  58.   If stars\speed>3 Then DrawImage stara,xx,yy
  59. ;  If stars\speed=1 Then Color 50,50,50
  60. ;  If stars\speed=2 Then Color 100,100,100
  61. ;  If stars\speed=3 Then Color 150,150,150
  62. ;  If stars\speed=4 Then Color 200,200,200
  63. ;  If stars\speed=5 Then Color 250,250,250
  64. ;  Plot xx,yy
  65.  Next
  66.  Color 0,0,0
  67.  Oval 260,180,120,120
  68. End Function